package cn.ytr.crm.web.controller;

import cn.ytr.crm.domain.Customer;
import cn.ytr.crm.service.ICustomerService;
import cn.ytr.crm.service.IDepartmentService;
import cn.ytr.crm.service.IEmployeeService;
import cn.ytr.crm.service.IPermissionService;
import cn.ytr.crm.util.RandomUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/test")
@Transactional
public class TestController {

    @Autowired
    private IEmployeeService employeeService;
    @Autowired
    private IPermissionService permissionService;
    @Autowired
    private IDepartmentService departmentService;
    @Autowired
    private ICustomerService customerService;

    /**
     * 处理 测试sql
     */
    @RequestMapping("/sql")
    public ModelAndView sqlTest(String name, String password) {

        for (int i = 0; i < 50; i++) {
            Customer customer = new Customer();
            customer.setName(RandomUtil.getRandomName());
            customer.setAge(RandomUtil.getRandomInt(1, 100));
            customer.setGender(RandomUtil.getRandomInt(0, 1));
            customer.setTel("" + RandomUtil.getRandomInt(0, 9) + RandomUtil.getRandomInt(0, 9) +
                    RandomUtil.getRandomInt(0, 9) + RandomUtil.getRandomInt(0, 9) + RandomUtil.getRandomInt(0, 9) +
                    RandomUtil.getRandomInt(0, 9) + RandomUtil.getRandomInt(0, 9) + RandomUtil.getRandomInt(0, 9) +
                    RandomUtil.getRandomInt(0, 9) + RandomUtil.getRandomInt(0, 9) + RandomUtil.getRandomInt(0, 9));
            customer.setQq("" + RandomUtil.getRandomInt(0, 9) + RandomUtil.getRandomInt(0, 9) + RandomUtil.getRandomInt(0, 9)
                    + RandomUtil.getRandomInt(0, 9) + RandomUtil.getRandomInt(0, 9) + RandomUtil.getRandomInt(0, 9)
                    + RandomUtil.getRandomInt(0, 9) + RandomUtil.getRandomInt(0, 9) + RandomUtil.getRandomInt(0, 9));
            customer.setInputTime(RandomUtil.getRandomDate("2019"));
            customer.setStatus(RandomUtil.getRandomInt(0, 4));

            customerService.saveOrUpate(customer);
        }
        System.out.println("sql执行ok");
        return null;
    }

}






































